<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path;
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>每周点评-云校通-教师</title>
<jsp:include page="/WEB-INF/page/common/_header.jsp"></jsp:include>
<body ontouchstart class="js-jf week-comment">
<div class="weui_tab tab-bottom">
	<div class="weui-header bg-blue"> 
  		<div class="weui-header-left"> <a onclick="back()" href="javascript:" class="icon icon-109 f-white">返回</a> </div>
    	<h1 class="weui-header-title">每周点评</h1>
    </div>
	<div class="weui_tab_bd">
    	<div class="weui_cells weui_cells_access mt0">
	        <div class="weui_cell">
		        <div class="weui_cell_hd">
		         	<label class="weui_label">请选择班级</label>
		        </div>
	    		<div class="weui_cell_bd weui_cell_primary">
					<input type="text" id="regTeacher" class="weui_input weui_input-select tr main1" value="请选择" readonly="readonly">
	   			</div>
	   			<div class="weui_cell_ft"></div>
			</div>
       </div>
       <div class="weui_cells mt0 mb40" id="studentList">
	   </div>
	</div>
</div>
<!--弹窗-->				
<div class="hide_bd1"></div>
<div class="hb_choose type2" style="top: 90px;width: 100%;left:0;">
	<div class="bj">
	</div>
</div>

<div class="hide_main" id="hide_main">
   <header>
     <h5><span id="studentName"></span> 写评语</h5>
     <img src="<%=basePath %>/images/iconC.png" onclick="hideComment()">
   </header>
   <ul id="weekList">
   </ul>
   <div class="tips">
     <h4>圆内数字“1、2、3...”代表第几周。</h4>
     <span class="bg-green"></span><p>绿色代表家长已回评语</p>
     <span class="bg-blue"></span><p>蓝色代表老师已填评语</p>
     <span class="bg-grey"></span><p>灰色代表老师未填评语</p>
   </div>
</div>

<div class="hide_main" id="hide_main1">
   <header>
     <h5>周期列表</h5>
     <img src="<%=basePath %>/images/iconC.png" onclick="hideComment()">
   </header>
   <ul id="weekList1">
   </ul>
   <div class="tips">
     <h4>圆内数字“1、2、3...”代表第几周。</h4>
   </div>
</div>
<div class="hide_black"></div>
<!--End弹窗-->
<script type="text/javascript">
	$(function(){
		$("#regTeacher").click(function() {
	    	$(".type2").show();
			$(".hide_bd1").attr("style", "display: block;");
		})
		$(document).on("click", ".hb_choose .title>li", function(e) {
			$(this).addClass("active").siblings().removeClass("active");
			$(".yng").hide();
			$("#" + $(this).attr("data-key")).show();
    	});
		$(document).on("click", ".list_3 .list_c3", function(e) {
			$("#regTeacher").val($(this).attr("data-name"));
			var dataValue = $(this).attr("data-value");
			$("#regTeacher").attr("data-value", dataValue);
			$(".type2").hide();
			$(".hide_bd1").attr("style", "display: none;");
			$("#totalDetail").show();
			var vy = dataValue.split("-");
			loadStudentList(vy[0], vy[1]);
		});
	    loadClass();
	})
	function showComment(thiz) {
		$(".hide_black").show();
  		$("#hide_main").show();
  		$("#studentName").html($(thiz).attr("data-name"));
  		weekCommentByStudentId($(thiz).attr("data-id"));
  	}
  	function hideComment() {
  		$(".hide_black").hide();
  		$("#hide_main").hide();
  		$("#hide_main1").hide();
  	}
  	function showComment1() {
  		$(".hide_black").show();
  		$("#hide_main1").show();
  		var obj = $($($("#studentList").find(".weui_cell")[1]).find(".weui_btn_mini")[1]);
  		var studentId = obj.attr("data-id");
  		var grade = obj.attr("data-grade");
  		var clazz = obj.attr("data-clazz");
  		weekCommentByStudentId1(studentId, grade, clazz);
  	}
	function weekCommentByStudentId1(studentId, grade, clazz) {
  		$.ajax({
			url : basePath + "/ls/week/comment/studentId",
			type : "post",
			data : {
				studentId: studentId, 
				grade: grade, 
				clazz: clazz
			},
			dataType : "json",
			async : false,
			success : function(data) {
				if(data != null) {
					var html = '';
					for(var i in data) {
						var itm = data[i];
						var bg = "bg-gray";
						var fg = "f-black";
						var link = basePath + "/ls/week/comment/lookList?wno=" + itm.weekNo + "&grade=" + grade + "&clazz=" + clazz;
						html += '<li class="'+bg+'"><a href="'+link+'" class="'+fg+'">'+itm.weekNo+'</a></li>';
					}
					$("#weekList1").html(html);
				}
			}, error:function(){
				$.alert("查询异常","");
			}
		});
  	}
  	function weekCommentByStudentId(studentId) {
  		$.ajax({
			url : basePath + "/ls/week/comment/studentId",
			type : "post",
			data : {
				studentId: studentId
			},
			dataType : "json",
			async : false,
			success : function(data) {
				if(data != null) {
					var html = '';
					for(var i in data) {
						var itm = data[i];
						var bg = "bg-gray";
						var fg = "f-black";
						var link = basePath + "/ls/week/comment/write?sid=" + studentId + "&wno=" + itm.weekNo;
						if(itm.status == 1) {
							bg = "bg-blue";
							fg = "f-white";
							link = basePath + "/ls/week/comment/detail/" + itm.commentId;
						} else if(itm.status == 2) {
							bg = "bg-green";
							fg = "f-white";
							link = basePath + "/ls/week/comment/detail/" + itm.commentId;
						}
						html += '<li class="'+bg+'"><a href="'+link+'" class="'+fg+'">'+itm.weekNo+'</a></li>';
					}
					$("#weekList").html(html);
				}
			}, error:function(){
				$.alert("查询异常","");
			}
		});
  	}
	function loadStudentList(grade, clazz){
		$.ajax({
			url : basePath + "/ls/week/comment/studentList",
			type : "post",
			dataType : "json",
			data: {
				grade: grade,
				clazz: clazz
			},
			async : false,
			success : function(data) {
				if(data != null) {
					var html = '<div class="weui_cell">\
		    			<div class="weui_cell_bd weui_cell_primary"><p></p></div>\
		       			<div class="weui_cell_ft f-blue" onclick="showComment1()">评语快捷查看</div>\
	       			</div>';
					for(var i in data) {
						var itm = data[i];
						html += '<div class="weui_cell">\
			                <div class="weui_cell_hd"><img class="circle bg-blue-b" src="<%=basePath %>/images/siliao_touxiang@3x.png" style="width:50px;margin-right:20px;display:block"></div>\
			                <div class="weui_cell_bd weui_cell_primary">\
			                    <p>'+itm.studentNum + '、' + itm.studentName+'</p>\
			                </div>\
			                <div class="weui_cell_ft">\
		                        <span style="position: relative;display: inline-block;">\
		                          <a href="<%=basePath%>/ls/week/comment/studentPage/'+itm.studentId+'" class="weui_btn weui_btn_mini bg-green-b">家长\
		                          <span class="weui-badge bg-green">'+itm.parentWeekNo+'</span>\
		                          </a> \
		                        </span>\
		           				<span style="position: relative;display: inline-block;">\
		                         		<a class="weui_btn weui_btn_mini bg-blue-b" data-grade="'+itm.grade+'" data-clazz="'+itm.clazz+'" data-id="'+itm.studentId+'" data-name="'+itm.studentName+'" onclick="showComment(this)">写评语\
		                         			<span class="weui-badge bg-blue ">'+itm.teacherWeekNo+'</span>\
		                         		</a>\
		                       	</span>\
			                </div>\
			            </div>';
					}
				}
				$("#studentList").html(html);
			}, error:function(){
				$.alert("查询异常","");
			}
		});
	}
	function loadClass() {
		$.ajax({
	   		url: basePath + "/classList",
	   		type: 'POST',
	   		dataType : "json",
	   		success: function(data) {
	   			if(data != null) {
	   				var html = '<ul class="title">';
	   				for(var i in data) {
	   					var itm = data[i];
	   					html += '<li class="'+(i == 0 ? "active " : "")+'" data-key="s'+itm.grade+'">'+itm.gradeText+'</li>';
	   				}
	   				html += "</ul>";
	   				for(var i in data) {
	   					var itm = data[i];
	   					html += '<div class="yng" id="s'+itm.grade+'"><ul class="list_3">';
	   					for(var j in itm.classList) {
	   						var itm1 = itm.classList[j];
	   						var gradeClass = itm1.grade + "-" + itm1.clazz;
	   						html += '<li><div class="weui_cell_hd list_c3 f-green" data-value="'+gradeClass+'" data-name="'+itm.gradeText+"(" + itm1.clazz +"班)"+'">\
										'+itm1.clazz+'班\
									</div></li>';
	   					}
	   					html += '</ul></div>';
	   				}
	   				$(".bj").html(html);
	   				$("#s" + data[0].grade).show();
	   			}
	   		},
	   		error: function(data) {
	   		}
	   	});
	}
</script>
<jsp:include page="/WEB-INF/page/common/_footer.jsp"></jsp:include>
</body>
</html>